//
//  BaseTableViewController.swift
//  sinaweibo
//
//  Created by 沈勇 on 16/5/2.
//  Copyright © 2016年 沈勇. All rights reserved.
//

import UIKit
import AFNetworking


class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    
    //添加用户是否登录标记
    var userLogin = false
    var visitorLoginView: VisitorLoginView?
    
    
    //MARK: 实现代理协议方法
    func visitorWillLogin() {
        
        print("come on")
        
    }
    
    func visitorWillRegister() {
        print("come in")
    }
    
    
    
    //loadView是苹果专门为手写代码准备的，等效于sb/xib
    //一旦实现这个方法，xib/sb 就会自动失效
    override func loadView() {
        
        userLogin ? super.loadView() : loadVisitorView()
        
        
    }
    
    private func loadVisitorView() {
        
        visitorLoginView = VisitorLoginView()
        
        visitorLoginView?.visitorDelegate = self
        
        view = visitorLoginView
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorWillRegister")
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }

}
